#include <51func.h>
typedef struct node_s{
    int num;
    struct node_s * pNext;
} node_t;
typedef struct list_s {
    node_t * pHead;
    node_t * pTail;
} list_t;
int tailInsert(node_t **ppHead,node_t ** ppTail,int num){
    node_t *pNew = (node_t *)malloc(sizeof(node_t));
    pNew->num = num;
    pNew->pNext = NULL; // 不可省略
    if(*ppHead == NULL){
        *ppHead = pNew;
        *ppTail = pNew;
    }
    else{
        (*ppTail)->pNext = pNew;
        *ppTail = pNew;
    }
    return 0;
}
int visitList(node_t *pHead){
    node_t *pCur = pHead;
    while(pCur){
        printf("%3d", pCur->num);
        pCur = pCur->pNext;
    }
    printf("\n");
    return 0;
}
void *threadFunc(void *arg){
    list_t * pList = (list_t *)arg;
    printf("I am child thread!\n");
    visitList(pList->pHead);
}
int main(int argc, char *argv[])
{
    list_t list;
    list.pHead = NULL;
    list.pTail = NULL;
    for(int i = 1; i <= 6; ++i){
        tailInsert(&list.pHead,&list.pTail,i);
    }
    pthread_t tid;
    pthread_create(&tid,NULL,threadFunc,&list); // list_t * --> void *
    pthread_join(tid,NULL);
    return 0;
}

